import { app1 as request } from '@/api/request';
/**
 * @description 获取用户信息
 * @method Get
 */
export function getPubUser<R, T>() {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/getPubUser');
}

/**
 * @description 获取全部专票数据
 * @method Get
 */
export function getAllRecord<R, T>() {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/list');
}

/**
 * @description 关键字搜索专票数据
 * @method Get
 */
export function getRecordByKeyword<R, T>(keyword: any) {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/searchkeyword', {
    params: {
      keyword,
    },
  });
}

/**
 * @description 单条专票插入
 * @method
 */
export function SingleUpload<R, T>(formState: any) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/SingleUpload', formState);
}

/**
 * @description 修改专票
 * @method Post
 */
export function updateData<R, T>(newData: any) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/update', newData);
}

/**
 * @description 删除单条记录
 * @method
 */
export function deleteRecord<R, T>(id: number) {
  const url = `/app1-vatinvoinceprintlog/delete?id=${id}`;
  return request.Delete<R, T>(url, {
    params: {
      id,
    },
  });
}

/**
 * @description 根据组织清空记录
 * @method Delete
 */
export function deleteAll<R, T>() {
  return request.Delete<R, T>('/app1-vatinvoinceprintlog/deleteall');
}

/**
 * @description 根据组织清空记录
 * @method Delete
 */
export function deleteByArea<R, T>(area: any) {
  const url = `/app1-vatinvoinceprintlog/deleteAllbyArea?area=${area}`;
  return request.Delete<R, T>(url, {
    params: {
      area,
    },
  });
}

/**
 * @description 上传excel文件
 * @method Post
 */
export function uploadData<R, T>(FormData: any) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/Fileupload', FormData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}

/**
 * @description 下载全部excel文件
 * @method Get
 */
export function exportAllData<R, T>() {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/AllFileExport', {
    responseType: 'blob',
  });
}

/**
 * @description 下载选择的excel文件
 * @method Post
 */
export function exportData<R, T>(integers: number[]) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/FileExport', integers, {
    responseType: 'blob',
  });
}

/**
 * @description 查询组织所有专票记录
 * @method Get
 */
export function getAllRecordByOrgName<R, T>(area: any) {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/listbyarea', {
    params: {
      area,
    },
  });
}

/**
 * @description 搜索组织专票记录
 * @method Get
 */
export function getRecordByKeyAndOrg<R, T>(keyword: any, area: any) {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/searchkeywordbyarea', {
    params: {
      keyword,
      area,
    },
  });
}

/**
 * @description 批量删除传票记录
 * @method Delete
 */
export function deleteRecordById<R, T>(integers: number[]) {
  return request.Delete<R, T>('/app1-vatinvoinceprintlog/deleteids', integers);
}

/**
 * @description 分页查询
 * @method Post
 */
export function getPage<R, T>(currentPage: number, pageSize: number) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/page', { currentPage, pageSize }, {
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * @description 修改打印状态
 * @method Post
 */
export function updatePrintflag<R, T>(ids: number[]) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/updatePrintflag', ids);
}

/**
 * @description 导出专票信息excel模板
 * @method Get
 */
export function getDownExcel<R, T>() {
  return request.Get<R, T>('/app1-vatinvoinceprintlog/exportTicketTemplate', {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    responseType: 'blob',
  });
}

/**
 * @description 根据组织分页专票查询
 * @method Post
 */
export function getPageByArea<R, T>(currentPage: number, pageSize: number, area: string) {
  return request.Post<R, T>('/app1-vatinvoinceprintlog/byAreaPage', { currentPage, pageSize }, {
    headers: {
      'Content-Type': 'application/json',
    },
    params: { area },
  });
}
